{%include file="index.header.tpl.php"%}
<link rel="stylesheet" href="static/css/select2.css">
{%include file="index.left.tpl.php"%} 
<!--主要内容开始-->
<div class="content-wrapper">
  <section class="content">
    <div class="row">
      <section class="col-lg-12 connectedSortable">
        <div class="box box-default box-solid">
          <form name="myform" action="" method="post" role="form" enctype="multipart/form-data">
            <div class="box-header with-border"> <span class="fa fa-pencil" style="float:left; font-size:18px; padding-top:3px; color:#3c8dbc;" ></span>
              <p class="box-title">教学成果添加</p>
            </div>
            <div class="box-body">
              <input type="hidden" name="achieve_type" value="{%$type%}">
              <div class="form-group">
                <label for="inputPassword3" class="col-md-3 control-label text-right" style="padding-right:0; padding-left:0; font-weight:500;"> 获奖名称： </label>
                <div class="input-group col-md-6 col-sm-12 col-xs-12">
                  <input type="text" value="{%$data.achieve_name%}" name="achieve_name" class="form-control" required>
                </div>
              </div>
              {%if $type eq 6 %}
              <div class="form-group">
                <label for="inputPassword3" class="col-md-3 control-label text-right" style="padding-right:0; padding-left:0; font-weight:500;"> 出版社： </label>
                <div class="input-group col-md-6 col-sm-12 col-xs-12">
                  <select class="form-control" id="s1" onchange="a()" name="achieve_publish">
                    <option value="请选择"> 请选择</option>
                    
										{%foreach from=$publish_lists key=key item=value%}
										
                    <option value="{%$value.publish_id%}" {%if $data.achieve_publish eq $value.publish_id %}selected{%/if%}>{%$value.publish_name%}</option>
                    
										{%/foreach%}
										
                    <option value="自定义"> 自定义</option>
                  </select>
                  <input id="new" class="form-control" placeholder="添加新的" name="resttype_name">
                  <span class="btn btn-default" id="add">添加</span> </div>
              </div>
              <div class="form-group">
                <label for="inputPassword3" class="col-md-3 control-label text-right" style="padding-right:0; padding-left:0; font-weight:500;"> 书号： </label>
                <div class="input-group col-md-6 col-sm-12 col-xs-12">
                  <input type="text" value="{%$data.achieve_bookno%}" name="achieve_bookno" class="form-control" required>
                </div>
              </div>
              <div class="form-group">
                <label for="inputPassword3" class="col-md-3 control-label text-right" style="padding-right:0; padding-left:0; font-weight:500;"> 所在页： </label>
                <div class="input-group col-md-6 col-sm-12 col-xs-12">
                  <input type="text" value="{%$data.achieve_page%}" name="achieve_page" class="form-control" required>
                </div>
              </div>
              {%/if%}
              {%if $type neq 6 %}
              <div class="form-group">
                <label for="inputPassword3" class="col-md-3 control-label text-right" style="padding-right:0; padding-left:0; font-weight:500;"> 主办单位： </label>
                <div class="input-group col-md-6 col-sm-12 col-xs-12">
                  <input type="text" value="{%$data.achieve_unit%}" name="achieve_unit" class="form-control" required>
                </div>
              </div>
              {%if $type neq 7%}
              <div class="form-group">
                <label for="inputPassword3" class="col-md-3 control-label text-right" style="padding-right:0; padding-left:0; font-weight:500;"> 获奖名次： </label>
                <div class="input-group col-md-6 col-sm-12 col-xs-12">
                  <select class="form-control" name="achieve_rank">
                    
										{%foreach from=$prize key=key item=value%}
										
                    <option value="{%$value.prize_id%}" {%if $data.achieve_rank eq $value.prize_id %}selected{%/if%}> {%$value.prize_name%}</option>
                    
										{%/foreach%}
									
                  </select>
                </div>
              </div>
              {%else%}
              <div class="form-group">
                <label for="inputPassword3" class="col-md-3 control-label text-right" style="padding-right:0; padding-left:0; font-weight:500;"> 第一指导老师： </label>
                <div class="input-group col-md-6 col-sm-12 col-xs-12">
                  <select class="form-control" name="achieve_teach">
                    
										{%foreach from=$teachers key=key item=value%}
										
                    <option value="{%$value.staff_id%}" {%if $data.achieve_teach eq $value.staff_id %}selected{%/if%}> {%$value.staff_name%}({%$value.staff_number%})</option>
                    
										{%/foreach%}
									
                  </select>
                </div>
              </div>
              <div class="form-group">
                <label for="inputPassword3" class="col-md-3 control-label text-right" style="padding-right:0; padding-left:0; font-weight:500;"> 本人名次： </label>
                <div class="input-group col-md-6 col-sm-12 col-xs-12">
                  <input type="text" value="{%$data.achieve_trank%}" name="achieve_trank" class="form-control" required>
                </div>
              </div>
              {%/if%}
              {%/if%}
              <div class="form-group">
                <label for="inputPassword3" class="col-md-3 control-label text-right" style="padding-right:0; padding-left:0; font-weight:500;"> 获奖级别： </label>
                <div class="input-group col-md-6 col-sm-12 col-xs-12">
                  <select class="form-control" name="achieve_lv">
                    
										{%foreach from=$prizelv key=key item=value%}
										
                    <option value="{%$value.prizelv_id%}" {%if $data.achieve_lv eq $value.prizelv_id %}selected{%/if%}> {%$value.prizelv_name%}</option>
                    
										{%/foreach%}
									
                  </select>
                </div>
              </div>
              <div class="form-group">
                <label for="inputPassword3" class="col-md-3 control-label text-right" style="padding-right:0; padding-left:0; font-weight:500;"> {%if $type eq 6%}发表者{%else%}获奖人{%/if%}： </label>
                <div class="input-group col-md-6 col-sm-12 col-xs-12"> {%if $type eq 5%}
                  <input type="text" name="achieve_owner" id="achieve_owner" value="{%$data.achieve_owner%}" class="form-control" required>
                  {%else%}
                  <select class="form-control" name="achieve_owner">
                    
										{%foreach from=$teachers key=key item=value%}
										
                    <option value="{%$value.staff_id%}" {%if $data.achieve_owner eq $value.staff_id %}selected{%/if%}> {%$value.staff_name%}({%$value.staff_number%})</option>
                    
										{%/foreach%}
									
                  </select>
                  {%/if%} </div>
              </div>
              <div class="form-group">
                <label for="inputPassword3" class="col-md-3 control-label text-right" style="padding-right:0; padding-left:0; font-weight:500;"> {%if $type eq 6%}发表日期{%else%}获奖日期{%/if%}： </label>
                <div class="input-group col-md-6 col-sm-12 col-xs-12">
                  <input type="text" value="{%$data.achieve_time%}" class="form-control" name="achieve_time"  id="datepicker" />
                  <div class="input-group-addon"> <i class="fa fa-calendar"></i> </div>
                </div>
              </div>
              {%if $type eq 5 %}
              <div class="form-group">
                <label for="inputPassword3" class="col-md-3 control-label text-right" style="padding-right:0; padding-left:0; font-weight:500;"> 第一指导老师： </label>
                <div class="input-group col-md-6 col-sm-12 col-xs-12">
                  <select class="form-control" name="achieve_teach">
                    
										{%foreach from=$teachers key=key item=value%}
										
                    <option value="{%$value.staff_id%}" {%if $data.achieve_teach eq $value.staff_id %}selected{%/if%}> {%$value.staff_name%}({%$value.staff_number%})</option>
                    
										{%/foreach%}
									
                  </select>
                </div>
              </div>
              <div class="form-group">
                <label for="inputPassword3" class="col-md-3 control-label text-right" style="padding-right:0; padding-left:0; font-weight:500;"> 其他指导老师： </label>
                <div class="input-group col-md-6 col-sm-12 col-xs-12">
                  <select class="form-control select2" name="achieve_teachers[]" multiple="multiple" data-placeholder="选择老师（可多选）">
                    
										{%foreach from=$teachers key=key item=value%}
										
                    <option value="{%$value.staff_id%}" {%if $value.staff_id|in_array:$data.achieve_teachers %}selected{%/if%}> {%$value.staff_name%}({%$value.staff_number%})</option>
                    
										{%/foreach%}
									
                  </select>
                </div>
              </div>
              {%/if%}
              <div class="form-group">
                <label for="inputPassword3" class="col-md-3 control-label text-right" style="padding-right:0; padding-left:0; font-weight:500;"> 备注： </label>
                <div class="input-group col-md-6 col-sm-12 col-xs-12">
                  <input type="text" value="{%$data.achieve_remark%}" name="achieve_remark" class="form-control" required>
                </div>
              </div>
              <div class="form-group">
                <label for="inputPassword3" class="col-md-3 control-label text-right" style="padding-right:0; padding-left:0; font-weight:500;"> 附件： </label>
                <div class="input-group col-md-6 col-sm-12 col-xs-12"> {%if $data.achieve_file!=""%} <br>
                  <input type="radio" name="achieve_file_re" value="0" checked>
                  <a href="upload/achieve_file/{%$data.achieve_file%}" target="_blank">{%$data.achieve_file%}</a> <br>
                  <br>
                  <input type="radio" name="achieve_file_re" value="1" >
                  重新上传
                  <input id="achieve_file" name="achieve_file" type="file" size="60"/>
                  {%else%}
                  <input id="achieve_file" name="achieve_file" type="file" size="60"/>
                  <input type="hidden" name="achieve_file_re" value="1">
                  {%/if%} </div>
              </div>
              {%if $type eq 5%}
              <div class="form-group">
                <label for="inputPassword3" class="col-md-3 control-label text-right" style="padding-right:0; padding-left:0; font-weight:500;"> 是否同步到指导老师奖： </label>
                <div class="input-group col-md-6 col-sm-12 col-xs-12">
                  <input type="checkbox" name="same">
                </div>
              </div>
              {%/if%} </div>
            <!--box-body -->
            <div class="box-footer text-center">
              <button class="btn btn-primary" type="submit">保 存 信 息</button>
            </div>
          </form>
        </div>
        <!--box box-default box-solid--> 
      </section>
    </div>
    <!--row--> 
  </section>
</div>
<!--主要内容结束--> 
{%include file="index.footer.tpl.php"%} 
<script>
	$(function() {
		$( "#datepicker" ).datepicker({
			showOtherMonths: true,
			selectOtherMonths: true,
			changeMonth: true,
			changeYear: true,
		});
		$( "#datepicker1" ).datepicker({
			showOtherMonths: true,
			selectOtherMonths: true,
			changeMonth: true,
			changeYear: true
		});
		$( "#datepicker2" ).datepicker({
			showOtherMonths: true,
			selectOtherMonths: true,
			changeMonth: true,
			changeYear: true
		});
		$( "#datepicker3" ).datepicker({
			showOtherMonths: true,
			selectOtherMonths: true,
			changeMonth: true,
			changeYear: true
		});
	});
	//上传图片
	$(function(){
		var imgurl=[];
		function createfile(){
			$('#updiv').append("<input type='file'  name='photos' class='upfile'>");
		}
		function showimg(url){
			var img='<img src="'+url+'"/>';
			$('#imglist').append(img);
		}
		function addfile(){
			showimg($(this).val());
			$(this).hide();
			createfile();
			$('.upfile').bind('change',addfile);
		}
		$('.upfile').bind('change',addfile);
	})
</script> 
{%if $type eq 6 %} 
<script type="text/javascript">
	$(document).ready(function(){
		$("#new").hide();
		$("#add").hide();

		$("#add").click(function(){
			var na=$("#new").val();
			$.ajax({
				url:"index.php?a=publish.addajax&name="+na,
				type:"get",
				dataType: "json",
				success: function (msg) {
					if(msg!=""){
						$("#s1").append("<option value='"+msg+"'>"+$("#new").val()+"</option>");
						$("#new").val('');
					}
				}
			});

		});
	});
	function a()
	{
		var val = $("#s1").val();
		if (val == '自定义') {
			$("#new").show();
			$("#add").show();
		} else{
			$("#new").hide();
			$("#add").hide();
		};
	}
</script> 
{%/if%} 
<script src="static/js/select2.min.js"></script> 
<script>
	$(function() {
		$(".select2").select2();
	});
</script>